package top.system.dept.config;

import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

public class WebMVCConfig implements WebMvcConfigurer {

    public static final String imgSavePath = "/static/upload/imgs/";
    public static final String invoiceSavePath = "/static/upload/invoice_files/";

    // 这里定义了static路径，所以resources下的static路径不再生效
    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {
        String resourceLocation = System.getProperty("user.dir");
        registry.addResourceHandler(imgSavePath + "**").addResourceLocations(resourceLocation + imgSavePath);
        registry.addResourceHandler(invoiceSavePath + "**").addResourceLocations(resourceLocation + invoiceSavePath);
    }
}
